Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

466
Views
Is there a way to get npm install to install "bin" executables in the local node_modules directory (the .bin directory)?

I have a Node project, and I can npm pack it into a tarball and install it in another directory for testing. When I do that, the set of files in the "bin" clause of my package.json are correctly symlinked into the node_modules/.bin directory there. Thus I can use npx something to run the "something" script and it works as I would expect.

From the actual project directory, however, npm install doesn't do that. The scripts are there in my top-level "bin" directory of course, but npx doesn't find them. Obviously I could just run them directly, but it would be nice if I could run the same shell commands to run them in other installation directories and in the project home directory.

I don't want to install the package globally; I want to keep everything local, at least for now. So can I get npm to make those symlinks for me, or should I just bite the bullet and do it myself?

Here's my package.json:

{
  "name": "@foo/plazadb",
  "version": "0.1.0",
  "description": "Basic database setup with upload/download from CSV",
  "main": "lib/plazadb.js",
  "author": "Pointy",
  "license": "ISC",
  "dependencies": {
    "arg": "^5.0.1",
    "cls-hooked": "^4.2.2",
    "csv-parser": "^3.0.0",
    "csv-stringify": "^6.0.5",
    "neat-csv": "^7.0.0",
    "pg": "^8.7.*",
    "sequelize": "^6.16.*"
  },
  "bin": {
    "conntest": "./bin/conntest.js",
    "download": "./bin/download.js",
    "upload": "./bin/upload.js"
  }
}

The "bin" files all exist (of course, otherwise they would never work). What I'm trying (out of ignorance) is a simple npm install from the project directory.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

One way to do is by

  1. specifying a local prefix by using npm config set prefix <path> or one of these methods linked here.
  2. generating symlinks using npm link

As a word of caution, to undo npm link executing npm unlink . may not work. Instead one may have to run npm uninstall -g ..

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!